package com.baomidou.kisso.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;

import java.io.Serializable;

/**
 * 统一API响应结果封装
 *
 * @author cui.zhen@foxmail.com
 * @date 2017/11/3 下午1:13
 */
public class Result<T> implements Serializable {
    private static final long serialVersionUID = -8598958602264325171L;
    private int code;
    private String message;
    private T data;
    private String status;
    @JsonIgnore
    public Result setCode(ResultCode resultCode) {
        this.code = resultCode.code;
        if (this.code == ResultCode.SUCCESS.code) {
            this.status = "success";
        } else {
            this.status = "error";
        }
        return this;
    }

    public int getCode() {
        return this.code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return this.message;
    }

    public Result setMessage(String message) {
        this.message = message;
        return this;
    }

    public T getData(){
        return data;
    }

    public Result<T> setData(T data){
        this.data = data;
        return this;
    }
}